package WaiBao;

import java.util.Arrays;

public class QuShuYang {
    public static void main(String[] args) {
        String[] name = {"文天祥(班长)","李时珍(团支书)", "小李(学习委员)","李茂贞(文艺委员)", "李星云", "候清", "李道", "王道", "小黑", "大白", "小蓝", "小智",
                "张村发", "张胜天", "李志辉", "王聪明", "迪奥", "圣罗兰", "兰蔻", "谷雨", "阿迷", "雅诗兰黛", "SKTWO", "李晓", "梁山", "张艺兴", "李浩存", "杨之光",
                "韩信", "渠舒洋 (学生)"};//考生本人: 渠舒洋 (学生)
        int[] age = {20, 18, 18, 17, 19, 20, 19, 21, 19, 19, 18, 18, 18, 20, 20, 19, 18, 18, 18, 18, 19, 19, 20, 20, 20, 18, 20, 18, 18, 19};//最后一位：考生年龄:19

        double[] mongo1 = {78, 72, 71, 86, 78, 79, 78, 89, 81, 90, 91, 87, 85, 79, 65, 68, 99, 99, 96, 88, 92, 91, 95, 65, 75, 74, 94, 74, 88, 95};
        double[] mongo2 = {79, 74, 84, 84, 74, 94, 98, 69, 70, 90, 90, 77, 66, 85, 65, 65, 76, 99, 66, 98, 72, 71, 95, 86, 75, 88, 84, 64, 80, 96};
        double[] mongo3 = {72, 78, 82, 91, 76, 89, 78, 69, 80, 80, 93, 87, 85, 65, 65, 68, 69, 96, 96, 93, 92, 81, 65, 95, 76, 84, 73, 71, 89, 95};


        double tangguo ;//代表每个学生的总分
        double oppo;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            tangguo  = mongo1[i] +mongo2[i] + mongo3[i];
//            oppo = (tangguo * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + tangguo);
//            System.out.println(name[i] + "的平均分为:" + oppo);
//        }


        double shuzi = 0,xiaocao= 0;
        double[]  juhua  = new double[30];
//        for (int i = 0; i < 30; i++) {
//            shuzi = mongo1[i] +  mongo2[i] + mongo3[i];
//            xiaocao = (shuzi* 1.0) / 3;
//            juhua [i] = xiaocao;
//        }
//
//        for (int i = 0; i < juhua.length - 1; i++) {
//            for (int j = 0; j <  juhua .length - i - 1; j++) {
//                if (juhua [j] < juhua [j + 1]) {
//                    double tep = juhua[j];
//                    juhua[j] = juhua[j + 1];
//                    juhua[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(juhua[i]);
//        }



        double hehua1 = 0,  hehua2 = 0, hehua3 = 0;//计算每门课的平均分
        double midexiang1 = 0,midexiang2 = 0,midexiang3 = 0;//计算每门课标准差
        double lizi1 = 0, lizi2 = 0,lizi3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i < mongo1.length; i++) {
            he += mongo1[i];
        }
        hehua1 = (he * 1.0) / 30;
        System.out.println("农业设施及环境调控的班级平均分为:" + hehua1);
        double Sum = 0;
        for (int i = 0; i < mongo2.length; i++) {
            Sum +=mongo2[i];
        }
        hehua2 = (Sum * 1.0) / 30;
        System.out.println("农业设施设计与建造的班级平均分为:" + hehua2);
        double sum = 0;
        for (int i = 0; i < mongo3.length; i++) {
            sum +=mongo3[i];
        }
        hehua3 = (sum * 1.0) / 30;
        System.out.println("园艺植物设施栽培学的班级平均分为:" +  hehua3);



        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i <mongo1.length; i++) {
            c1 += (mongo1[i] -  hehua1) * (mongo1[i] - hehua1);
        }
        midexiang1 = Math.sqrt(c1*1.0/30);
        System.out.println("农业设施及环境调控的班级标准差为:" + midexiang1);
        for (int i = 0; i < mongo2.length; i++) {
            c2 += (mongo2[i] -  hehua2) * (mongo2[i] - hehua2);
        }
        midexiang2 = Math.sqrt(c2*1.0/30);
        System.out.println("农业设施设计与建造的班级标准差为:" +midexiang2);

        for (int i = 0; i <mongo3.length; i++) {
            c3 += (mongo3[i] -  hehua3) * (mongo3[i] -  hehua3);
        }
        midexiang3 = Math.sqrt(c3*1.0/30);
        System.out.println("园艺植物设施栽培学的标准差为:" + midexiang3);
////////
//////
//        Arrays.sort(mongo1);
//        Arrays.sort(mongo2);
//        Arrays.sort(mongo3);
//        lizi1 = (mongo1[14] + mongo1[15]) * 1.0 / 2;
//        lizi2 = (mongo2[14] +mongo2[15]) * 1.0 / 2;
//        lizi3 = (mongo3[14] + mongo3[15]) * 1.0 / 2;
//        System.out.println("农业设施及环境调控的中位数为:" +  lizi1);
//        System.out.println("农业设施设计与制造的中位数为:" +  lizi2);
//        System.out.println("园艺植物设施栽培学的中位数为:" +  lizi3);




    }
}
